package com.hmy.infrastructure.controller;

import com.hmy.ccp.common.result.JsonResult;
import com.hmy.ccp.error.annotations.HmyGateWayController;
import com.hmy.infrastructure.bo.response.DistrictResponse;
import com.hmy.infrastructure.service.IDistrictService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 行政区划
 * @author Lyn 宋开放
 * @date 2023-12-20 21:22
 **/
@RestController
@RequestMapping("/api/district")
@HmyGateWayController
public class DistrictController {

    private final IDistrictService districtService;

    /**
     * 统一注入
     * @param districtService 行政区划业务逻辑函数定义
     */
    public DistrictController(IDistrictService districtService) {
        this.districtService = districtService;
    }

    /**
     * 获取完整行政区划树
     *
     * @return 行政区划树
     */
    @GetMapping("/tree")
    public JsonResult<List<DistrictResponse>> tree(){
        return JsonResult.success(districtService.getDistrictTree());
    }
}
